package com.briup.app02.web.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.briup.app02.bean.BaseRole;
import com.briup.app02.service.IBaseRoleService;
import com.briup.app02.utils.Message;
import com.briup.app02.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("/baserole")
@Api(description = "角色管理")
public class RoleController {
	@Autowired
    private IBaseRoleService baseroleService;
	
	
	@GetMapping("findAll")
	@ApiOperation("查询所有角色信息")
	public Message findAll(){
		List<BaseRole> list=baseroleService.findAll();
		return MessageUtil.success(list);
	}
	@GetMapping("findById")
	@ApiOperation("根据id查询角色信息")
	@ApiImplicitParam(name ="id",value = "角色id",dataType = "long",paramType = "query",required = true)
	public BaseRole findById(long id) {
		return baseroleService.findById(id);
	}
	@PostMapping("saveOrUpdate")
	@ApiOperation(value="保存或更新",notes = "id为空是保存否则是更新")
	public Message saveOrUpdate(BaseRole baserole) {
		baseroleService.saveOrUpdate(baserole);
		return MessageUtil.success("操作成功");
	}
	@DeleteMapping("deleteById")
	@ApiOperation("根据id删除用户信息")
	@ApiImplicitParam(name="id",value = "角色id",dataType = "long",paramType = "query",required = true)
	public Message deleteById(long id) {
		baseroleService.deleteById(id);
		return MessageUtil.success("删除成功");
	}
	
}
